We have extended the classical over-barrier model to simulate the neutralization dynamics of highly charged ions interacting under grazing incidence with conducting and insulating surfaces. Our calculations are based on simple model rates for resonant and Auger transitions. We include effects caused by the dielectric response of the target and, for insulators, localized surface charges. Characteristic deviations regarding the charge transfer processes from conducting and insulating targets to the ion are discussed. We find good agreement with previously published experimental data for the image energy gain of a variety of highly charged ions impinging on Au, Al, LiF and KI crystals.